//
//  KZExt_LiteralExpression.swift
//  KZSwiftMoudel
//
//  Created by 朱凯 on 2018/5/4.
//  Copyright © 2018年 JooKey. All rights reserved.
//

import Foundation

// MARK: 用字面量自定义集合数据，用以代替Any，提高安全性
enum KZListValue {
    case int(Int)
    case string(String)
    case float(Float)
    case bool(Bool)
}
extension KZListValue: ExpressibleByStringLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByBooleanLiteral {
    typealias StringLiteralType     = String
    typealias IntegerLiteralType    = Int
    typealias FloatLiteralType      = Float
    typealias BooleanLiteralType    = Bool

    init(stringLiteral value: StringLiteralType) {
        self = .string(value)
    }
    init(integerLiteral value: IntegerLiteralType) {
        self = .int(value)
    }
    init(floatLiteral value: FloatLiteralType) {
        self = .float(value)
    }
    init(booleanLiteral value: BooleanLiteralType) {
        self = .bool(value)
    }
}
